{extend name="public:base"}
{block name='css'}
<link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
{/block}
{block name="js"}
<!--<script src="__PUBLIC__/js/plugins/peity/jquery.peity.min.js"></script>-->
<!--<script src="__PUBLIC__/js/content.min.js"></script>-->

<script type="text/javascript">
    function del(self, id){
        if ($(self).hasClass('ed')) {
            return false;
        }

        layer.confirm('真的要删除吗？删除后将无法找回！', {
            btn: ['确定','取消'] //按钮
        }, function(){
            myRequestRefresh(self, "{:url('business_del')}", {id:id});
        }, function(){

        });
    }

    function confirmPay(self, id){
        if ($(self).hasClass('ed')) {
            return false;
        }

        layer.confirm('确定要通过用户的申请吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            myRequestRefresh(self, "{:url('business_examine')}", {id:id,state:1});
        }, function(){

        });
    }

    function confirmRefuse(self, id){
        if ($(self).hasClass('ed')) {
            return false;
        }

        layer.confirm('确定要拒绝用户的申请吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            layer.prompt({title: '请输入拒绝理由，并确认', formType: 2}, function(text, index){
                layer.close(index);
                myRequestRefresh(self, "{:url('business_examine')}", {id:id,state:2,reason:text});
            });
        }, function(){

        });
    }
</script>
{/block}
{block name='body'}
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>商家管理</h5>
                    </div>
                    <div class="ibox-content">
						<div class="row">
							<form name="form" action="{:url('index')}" method="get">
                                <div class="col-sm-2 m-b-xs">
                                    <select name="state" class="input-sm  form-control">
                                        <option value="">审核状态</option>
                                        <option value="1" {if condition="input('state', 0, 'intval') eq 1"} selected {/if} >审核中</option>
                                        <option value="2" {if condition="input('state', 0, 'intval') eq 2"} selected {/if} >审核通过</option>
                                        <option value="3" {if condition="input('state', 0, 'intval') eq 3"} selected {/if} >审核不通过</option>
                                        <option value="2" {if condition="input('state', 0, 'intval') eq 4"} selected {/if} >修改信息审核通过</option>
                                        <option value="3" {if condition="input('state', 0, 'intval') eq 5"} selected {/if} >修改信息审核不通过</option>
                                    </select>
                                </div>
                                <div class="col-sm-3 m-b-xs">
                                    <div class="input-group">
                                        <input type="text" name="keywords" value="{:input('keywords')}" placeholder="商家名称/联系人姓名/联系人手机" class="input-sm input-sm form-control"> <span class="input-group-btn">
                                        <button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                    </div>
                                </div>
							</form>
                        </div>
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th>商家名称</th>
                                    <th>联系人姓名</th>
                                    <th>联系人手机</th>
                                    <th>商家地址</th>
                                    <th>品牌</th>

                                    <th>营业执照</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
								{volist name="list" id="li"}
                                <tr>
                                    <td>{$li.title}</td>
                                    <td>{$li.name}</td>
                                    <td>{$li.tel}</td>
                                    <td>{$li.address}</td>
                                    <td>{$li.band}</td>

                                    <td><a href="{$li.license}" target="_blank"><img src="{$li.license}" height="80px;"/></a></td>
                                    <td>
                                        {switch name="li.status"}
                                        {case value="1"}<a href="javascript:;" class="btn btn-primary btn-xs">审核中</a>{/case}
                                        {case value="2"}<a href="javascript:;" class="btn btn-info btn-xs">审核通过</a>{/case}
                                        {case value="3"}<a href="javascript:;" class="btn btn-danger btn-xs">审核不通过</a><br>{$li.reason}{/case}
                                        {case value="4"}<a href="javascript:;" class="btn btn-info btn-xs">修改信息审核中</a>{/case}
                                        {case value="5"}<a href="javascript:;" class="btn btn-danger btn-xs">修改信息审核不通过</a><br>{$li.reason}{/case}
                                        {/switch}
                                    </td>
                                    <td>
                                        {if condition="$li.status eq 1 || $li.status eq 4"}
										<a href="javascript:;" onclick="confirmPay(this, {$li.id})" class="btn btn-info btn-xs">通过</a>
                                        <a href="javascript:;" onclick="confirmRefuse(this, {$li.id})" class="btn btn-danget btn-xs">拒绝</a>
                                        {/if}
                                        {eq name="li.status" value="3"}
	                                    <a href="javascript:;" onclick="return del(this, {$li.id});" class="btn btn-danger btn-xs delete"><i class="fa fa-trash-o"></i> 删除</a>
                                        {/eq}
									</td>
                                </tr>
								{/volist}
                            </tbody>
							<tfoot>
								<tr>
                                    <td colspan="9">{$list->render()}</td>
                                </tr>
							</tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        
    </div>
    
</body>
{/block}
